#include <cstdio>
#include <iostream>
#include <cmath>
#include <cassert>
#include <string>

class ExprTree
{
public:
    ExprTree(std::string str) : str_(std::move(str)) {}
    int calc()
    {
        assert(str_.size() > 0);
        std::cout << "Calculating " << str_ << std::endl;
        return calc_(0, str_.size() - 1);
    }

private:
    size_t findLowestPriorityPos(size_t l, size_t r)
    {
        size_t pos = -1, pri = INF - 1, temp = 0;
        assert(l >= 0 && r < str_.size());
        for (size_t i = l; i <= r; ++i)
        {
            int cur = INF;
            switch (str_[i])
            {
            case '(':
                temp += 100;
                break;
            case ')':
                temp -= 100;
                break;
            case '+':
            case '-':
                cur = temp + 1;
                break;
            case '*':
            case '/':
                cur = temp + 2;
                break;
            case '^':
                cur = temp + 3;
                break;
            }
            if (cur <= pri)
            {
                pos = i, pri = cur;
            }
        }
        return pos;
    }
    int sumUpResult(int lhs, int rhs, char op)
    {
        switch (op)
        {
        case '+':
            return lhs + rhs;
        case '-':
            return lhs - rhs;
        case '*':
            return lhs * rhs;
        case '/':
            return lhs / rhs;
        case '^':
            return static_cast<int>(std::pow(lhs, rhs));
        }
        return 0;
    }
    int getValueFromString(size_t l, size_t r)
    {
        int val = 0;
        for (size_t i = l; i <= r; ++i)
        {
            if (isdigit(str_[i]))
            {
                val = val * 10 + str_[i] - '0';
            }
        }
        return val;
    }
    int calc_(size_t l, size_t r)
    {
        size_t pos = findLowestPriorityPos(l, r);
        if (pos == -1)
        {
            int val = getValueFromString(l, r);
            printf("%d", val);
            return val;
        }
        int lhs = calc_(l, pos - 1);
        printf(" ");
        int rhs = calc_(pos + 1, r);
        printf(" %c", str_[pos]);
        return sumUpResult(lhs, rhs, str_[pos]);
    }

private:
    static constexpr int INF = 0x3f3f3f3f;
    const std::string str_;
};

int main(int argc, const char **argv)
{
    std::string str;
    while (std::getline(std::cin, str))
    {
        ExprTree et(str);
        int ans = et.calc();
        printf("\nans = %d\n", ans);
    }
    return 0;
}
